<template>
  <div>
    <div class="sidebar-header" v-if="!isExpand">
      <div class="logo-action">
        <div class="logo">
          <img src="@/assets/images/chat/ai_logo.png" alt="">
          <span class="c-primary f-18">知也</span>
        </div>
        <img src="@/assets/images/chat/ai_icon2.png" alt="" class="action" @click="handleExpand">
      </div>
      <div class="new-chat-btn" @click="startNewChat">
        <img src="@/assets/images/chat/ai_icon1.png" alt="">
        开启新对话
      </div>
    </div>
    <div class="sidebar-expand" v-else>
      <img src="@/assets/images/chat/ai_logo.png" alt="" class="logo">
      <div class="expand-actions">
        <img src="@/assets/images/chat/ai_icon10.png" alt="" class="action" @click="handleExpand">
        <img src="@/assets/images/chat/ai_icon9.png" alt="" class="action" @click="startNewChat">
      </div>
    </div>
  </div>
</template>
<script setup>
const emit = defineEmits(["new-chat", "expand"]);

const isExpand = ref(false);
const handleExpand = () => {
  isExpand.value = !isExpand.value;
  emit("expand", isExpand.value);
}
const startNewChat = () => {
  emit("new-chat");
}
</script>
<style scoped lang="scss">
.sidebar-header {
  padding: 0px 0px 30px;

  .logo-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
  }

  .logo {
    display: flex;
    align-items: center;

    img {
      width: 40px;
      height: 40px;
      margin-right: 10px;
    }
  }

  .action {
    width: 18px;
    height: 15px;
    cursor: pointer;
  }

  .new-chat-btn {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.11);
    color: #045CFE;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;

    img {
      width: 16px;
      height: 15px;
      margin-right: 10px;
    }
  }
}

.sidebar-expand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 50;
  img {
    width: 16px;
    height: 15px;
    cursor: pointer;
  }

  .logo {
    width: 40px;
    height: 40px;
    margin-right: 20px;
  }

  .expand-actions {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 85px;
    padding: 8px 0;
    background: #FFFFFF;
    box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.11);
    border-radius: 10px;
    border: 1px solid #E8E8E8;
  }
}
</style>